public int countGoodRectangles(int[][] rectangles) {
    int max = 0;
    int ans = 0;
    for (int[] tmp : rectangles
    ) {
        int rec = Math.min(tmp[0], tmp[1]);
        if (rec > max) {
            max = rec;
            ans = 1;
        } else if (rec == max) {
            ans++;
        }
    }
    return ans;
}